<html>

<head>
<meta charset="UTF-8">
<title>物品申请</title>
</head>
<body>
	<link rel="stylesheet" type="text/css" href="/css/form.css">
	<script type="text/javascript" src="/js/apply.js"></script>
	<script type="text/javascript">
		$(".navigation span:first").text("添加申请");
	</script>
	<#include "/head.ftl"/>
	<div class="content">
		<div class="tab">
			<div class="tab-header">
				<a title="返回" class="btn btn-setting" onclick="back(this)">
					<i class="iconfont icon-undo"></i>
				</a> <a title="刷新" class="btn btn-setting" onclick="refresh(this)">
					<i class="iconfont icon-refresh"></i>
				</a> 
			</div>
			<div class="form-content">
				<form method="post" id="objectForm">
					<fieldset>
						<table>
							<tr>
								<td>申请主题：</td>
								<td><input type="text" name="apply.title" placeholder="请填写申请的主题，不超过30个字符" maxlength="30" value="${(applyObject.apply.title)?default('')}"></td>
							</tr>
							<tr>
								<td>物品类型：</td>
								<td>
									<#list types['apply_object'] as ta>
										<#if applyObject?? && ta.value==applyObject.type>
											<input type="radio" name="type" value="${ta.value}" checked="checked">${ta.name}
										<#elseif ta_index==0>
											<input type="radio" name="type" value="${ta.value}" checked="checked">${ta.name}
										<#else>
											<input type="radio" name="type" value="${ta.value}">${ta.name}
										</#if>
									</#list>
								</td>
							</tr>
							<tr>
								<td>物品明细：</td>
								<td></td>
							</tr>
							<tr>
								<td></td>
								<td>
									<div id="object">
										<table>
											<tr>
												<td>物品名称<font color="red">*</font></td>
												<td>物品单位<font color="red">*</font></td>
												<td>物品数量<font color="red">*</font></td>
												<td>备注</td>
												<td><a onclick="addObject()" style="background-color: rgba(0, 141, 76, 0.7);" title="添加物品"><i class="iconfont icon-jia"></i></a></td>
											</tr>
											<#if applyObject??>
												<#list (applyObject.applyObjectObject) as applyObjectObject>
													<tr data-index="${applyObjectObject_index}">
														<td><input type="text" name="applyObjectObject[${applyObjectObject_index}].name" placeholder="请填写物品名称" maxlength="15" value="${applyObjectObject.name}"></td>
														<td><input type="text" name="applyObjectObject[${applyObjectObject_index}].unit" placeholder="请填写物品单位" maxlength="10" value="${applyObjectObject.unit}"></td>
														<td><input type="text" name="applyObjectObject[${applyObjectObject_index}].count" placeholder="请填写物品数量" maxlength="10" value="${applyObjectObject.count}" class="count" onchange="countSum()" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"></td>
														<td><input type="text" name="applyObjectObject[${applyObjectObject_index}].remark" placeholder="请填写物品备注" maxlength="20" value="${applyObjectObject.remark}" class="remark" ></td>
														<td><a class="minus" onclick="minusObject(this)"><i class="iconfont icon-jian" title="删除物品"></i></a></td>
													</tr>
												</#list>
											<#else>
												<tr data-index="0">
													<td><input type="text" name="applyObjectObject[0].name" placeholder="请填写物品名称" maxlength="15"></td>
													<td><input type="text" name="applyObjectObject[0].unit" placeholder="请填写物品单位" maxlength="10"></td>
													<td><input type="text" name="applyObjectObject[0].count" placeholder="请填写物品数量" maxlength="10" class="count" onchange="countSum()" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"></td>
													<td><input type="text" name="applyObjectObject[0].remark" placeholder="请填写物品备注" maxlength="20" class="remark" ></td>
													<td><a class="minus" onclick="minusObject(this)"><i class="iconfont icon-jian" title="删除物品"></i></a></td>
												</tr>
											</#if>
											<tr>
												<td></td>
												<td></td>
												<td>合计：<span id="countSum">0</span></td>
												<td></td>
												<td></td>
											</tr>
										</table>
									</div>
								</td>
							</tr>
							<tr>
								<td>审批对象：</td>
								<td>
									<!-- <#if userinfo.deptOffice.leader??>
										<input id="applyOffice" type="hidden" name="apply.deptOffice" value="${userinfo.deptOffice.leader.id}">
										${userinfo.deptOffice.leader.name}
									<#else>
										无
									</#if> -->
									<input id="cc1" class="easyui-combobox" data-options="valueField: 'id',editable:false,textField: 'name',url: '/user/depts/get',onSelect: function(rec){var url = '/user/dept/office/get?id='+rec.id;$('#cc2').combobox('reset');$('#cc2').combobox('reload', url);}">
									<input name="apply.deptOffice" id="cc2" class="easyui-combobox" data-options="valueField:'id',textField:'name',editable:false">
								</td>
							</tr>
							
							<tr>
								<td colspan="2" style="text-align: center;">
									<!-- <input class="button" type="submit" value="保存为草稿"> -->
									<input type="hidden" name="apply.user.id" value="${userinfo.id}">
									<input type="hidden" name="id" value="${(applyObject.id)?default('')}">
									<input type="hidden" name="apply.id" value="${(applyObject.apply.id)?default('')}">
									<input class="button" type="submit" value="提交">
								</td>
							</tr>
						</table>
					</fieldset>
				</form>
			</div>
		</div>

	</div>
</body>
</html>